package com.yyyzzz.servlet;

import com.yyyzzz.DAO.impl.teacherDaoimpl;
import com.yyyzzz.DAO.teacherDao;
import com.yyyzzz.service.impl.teacherServiceImpl;
import com.yyyzzz.service.teacherService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

public class teacherCancellationServlet extends HttpServlet {
    @Override
    protected void doGet (HttpServletRequest req , HttpServletResponse resp) throws ServletException, IOException {
int No = Integer.parseInt (req.getParameter ("teacherNo"));
String pwd = req.getParameter ("teacherpassword");
        try {
            teacherService teacherService = new teacherServiceImpl();
            boolean b = teacherService.checktracher (No , pwd);
            if ( b==true ){
                teacherDao teacherDaoimpl = new teacherDaoimpl();
                teacherDaoimpl.deleteTeacher (No);
            }else{
                resp.getWriter ().write ("用户名或者密码不正确请重新输入1");
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace ();
        } catch (ClassNotFoundException e) {
            e.printStackTrace ();
        }
    }

    @Override
    protected void doPost (HttpServletRequest req , HttpServletResponse resp) throws ServletException, IOException {
       doGet (req , resp);
    }
}
